package com.xique.client.service.biz.service.impl;

import com.xique.client.bean.domain.ParkInfo;
import com.xique.client.bean.domain.SysUser;
import com.xique.client.bean.transform.WxAppUserTransform;
import com.xique.client.bean.vo.WxAppSysUserVO;
import com.xique.client.service.biz.service.IWxAppUserBizService;
import com.xique.client.service.service.IParkInfoService;
import com.xique.client.service.service.ISysUserService;
import com.xique.common.core.utils.SecurityUtils;
import com.xique.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author shd
 * @create 2021/11/3 13:23
 */
@Service
public class WxAppUserBizServiceImpl implements IWxAppUserBizService {

    @Autowired
    private ISysUserService sysUserService;

    @Autowired
    private IParkInfoService parkInfoService;

    @Override
    public AjaxResult userInfo() {

        Long userId = SecurityUtils.getUserId();
        Long parkId = SecurityUtils.getParkId();

        SysUser user = sysUserService.selectSysUserById(userId);

        ParkInfo parkInfo = parkInfoService.selectParkInfoWithAreaById(parkId);

        WxAppSysUserVO vo = WxAppUserTransform.transformWxAppSysUserVO(user, parkInfo);

        return AjaxResult.success(vo);
    }
}
